import scala.collection.mutable

object transcriptTest {

  def main(args: Array[String]): Unit = {

    //    val buf = new ListBuffer[Int]
    //    buf += 1
    //    buf += 2
    //    buf += 3
    //
    //    3 +=: buf
    //    println(buf.toList.mkString("[", ",", "]"))
    //
    //    val mutaSet = mutable.Set(1, 2, 3)
    //    mutaSet += 4
    //    println(mutaSet.toList.mkString("[", ",", "]"))
    //
    //
    //    val imutaSet = immutable.Set(1, 2, 4)
    //
    //    val text = "See Spot run. Run, Spot. Run!"
    //    val testArray = text.split("[ !,.]+")
    //    println(testArray.mkString("[", ",", "]"))
    //    println(text.split("[ !,.]+").filter(!_.startsWith("S")).map(_.toLowerCase).mkString("[", ",", "]"))
    //    Range.apply(1, 5).map(x => mult2(x))
    //
    //    import scala.collection.immutable.TreeSet
    //    val ts = TreeSet(9, 3, 1, 8, 0, 2, 7, 4, 6, 5)
    //    println(ts.mkString("[", ",", "]"))

    val strs = "See, Spot, run, Run, Spot, Run"
    wordCout(strs)

    val map = Map("see" -> 1,  "run" -> 3,  "spot" -> 2)
    println(map("see"))
    println(map("see1"))
  }

  def mult2(num: Int) = num * 2

  def wordCout(strs: String): Unit = {

    val counts = mutable.Map.empty[String, Int]

    for (str <- strs.split(",")) {
      var oldCount: Int = 0
      val word = str.toLowerCase
      if (counts.contains(word)) oldCount = counts(word)
      counts += (word -> (oldCount + 1))
    }
    println(counts)
  }
}
